/**
 * 
 */
package com.xb.cloud.common.model;

import com.xb.cloud.common.constant.DbConstants;

/**
 * @author kexue
 *
 */
public class PageParam {
	
	
	private int pageNum;
	
	private int pageSize;
	
	public PageParam(){}
	
	public PageParam(Integer pageNum, Integer pageSize) {
		
		this.pageNum = pageNum;
		this.pageSize = pageSize;
	}
	/**
	 * 入参合法性验证，和大小限制
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public static PageParam resetPageParam(Integer pageNum, Integer pageSize) {
		if (pageNum == null || pageNum <= 0) {
			pageNum = 0;
		}
		if (pageSize == null || pageSize <= 0) {
			pageSize = DbConstants.DEFAULT_PAGE_SIZE;
		} else if (pageSize > DbConstants.MAX_PAGE_SIZE) {
			pageSize=DbConstants.MAX_PAGE_SIZE;
		}
		return new PageParam(pageNum, pageSize);
	}
	
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	
}
